package stat;

public class StatPointDerivedStat extends DerivedStat {
    
    private int myLevel;
    //this is the number of stat points gained per level
    private final int pointsPerLevel = 3;
    
    public StatPointDerivedStat( StatType st, Stat... toCache) {
        super(st, toCache);
        myLevel = getFromCache(StatType.LEVEL);
        compute();
    }
    
    public StatPointDerivedStat( StatType st, int value, Stat... toCache ) {
        super(st, value, toCache);
        myLevel = getFromCache(StatType.LEVEL);
        //compute();
    }
    
    /**
     * compute the statpoints based on the previous number
     * of points and the level
     */
    public void compute() {
        if( myLevel < getFromCache(StatType.LEVEL) ) {
            setValue(getValue() + pointsPerLevel * (Math.abs(myLevel-getFromCache(StatType.LEVEL))));
            myLevel = getFromCache(StatType.LEVEL);
        }
    }

}
